using System;
using UnityEngine;
using UnityEngine.Events;

namespace DL.Tools
{
    [Serializable]
    public class BindableProperty<T>
    {
        [SerializeField]
        private T m_Value;

        public UnityEvent<T> OnValueChanged;
        public BindableProperty()
        {
            OnValueChanged = new();
            m_Value = default;
        }
        
        public T Value
        {
            get { return m_Value; }
            set
            {
                if (!value.Equals(m_Value))
                {
                    m_Value = value;
                    OnValueChanged.Invoke(m_Value);
                }
            }
        }
        
    }
}

